package chapter7.io;

import java.io.*;
import java.io.FileInputStream;

/**
 * Created by qpx on 2018/5/14.
 */
public class DataInputStreamTest {

    public static void main(String[] args) throws IOException {

        DataOutputStream dataOutputStream = new DataOutputStream(new FileOutputStream("D://ioData.txt"));
        dataOutputStream.writeInt(1);
        byte a = 1;
        dataOutputStream.writeByte(a);
        char b = 'a';
        dataOutputStream.writeChar(b);
        float c = 1f;
        dataOutputStream.writeFloat(c);
        double d = 1d;
        dataOutputStream.writeDouble(d);
        dataOutputStream.flush();
        dataOutputStream.close();

        DataInputStream dataInputStream = new DataInputStream(new FileInputStream("D://io1.txt"));
        System.out.println(dataInputStream.readInt());
        System.out.println(dataInputStream.readByte());
        System.out.println(dataInputStream.readChar());
        System.out.println(dataInputStream.readFloat());
        System.out.println(dataInputStream.readDouble());
    }
}
